package com.wodsy.phoenix.commons.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by admin on 2015/4/1.
 */
public class RegexUtils {


    /**
     *  判断是否符合邮件格式
     * @param email
     * @return
     */
     public static boolean isEmailFormat(String email){
         String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
         Pattern regex = Pattern.compile(check);
         Matcher matcher = regex.matcher(email);
         boolean isMatched = matcher.matches();
         return isMatched;
     }

    /**
     * 手机号
     * @param phone
     * @return
     */
    public static boolean isPhoneFormat(String phone){
        String check = "^(13[4,5,6,7,8,9]|15[0,8,9,1,7]|188|187)\\d{8}$";
        Pattern regex = Pattern.compile(check);
        Matcher matcher = regex.matcher(phone);
        boolean isMatched = matcher.matches();
        return isMatched;
    }

    /**
     * 账号格式是否正确
     * @return
     */
    public static boolean isAccountFormat(String account){
        String check = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$";  //不能全数字或者字母 并且长度在8-16位之间
        Pattern regex = Pattern.compile(check);
        Matcher matcher = regex.matcher(account);
        boolean isMatched = matcher.matches();
        return isMatched;
    }

}
